/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.clyme.expediente.hibernate;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.hibernate.Session;


/**
 *
 * @author user
 */
public class HibernateListener implements ServletContextListener{
    private final String clase ="[HibernateListener]";
    
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        if(session == null){
        }else{
            session.close();
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        HibernateUtil.getSessionFactory().close();
    }
    
}
